package com.Shoping.dao.impl;

import com.Shoping.dao.CategoryDao;
import com.Shoping.entity.Category;
import com.Shoping.util.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class CategoryDaoImpl implements CategoryDao {
    private QueryRunner queryRunner = new QueryRunner();
    @Override
    public Category selectByCgId(Integer cgId) throws SQLException {
        String sql = "SELECT cg_id cgId,cg_name cgName FROM category WHERE cg_id=?;";
        return queryRunner.query(DbUtils.getConnection(),sql,new BeanHandler<>(Category.class),cgId);
    }
}
